| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | List of all members
nkAstraeus::FxaaEffect Class Referencefinal

A Fast Approximate Anti-Aliasing effect. More...

Inheritance diagram for nkAstraeus::FxaaEffect:

## Public Member Functions
| FxaaEffect (System *system) noexcept
virtual | ~FxaaEffect ()
nkGraphics::Texture * | getSourceTexture () const
float | getMinContrast () const
float | getMinLuminance () const
float | getSmoothingStrength () const
FXAA_PRESET | getPreset () const
bool | getLuminanceAsGreenChannelOnly () const
void | setSourceTexture (nkGraphics::Texture *value)
void | setMinContrast (float value)
void | setMinLuminance (float value)
void | setSmoothingStrength (float value)
void | setPreset (FXAA_PRESET value)
void | setLuminanceAsGreenChannelOnly (bool value)
virtual bool | load () override
virtual void | unload () override
Public Member Functions inherited from nkAstraeus::Effect
| Effect (EFFECT_TYPE type) noexcept
virtual | ~Effect ()
nkMemory::StringView | getName () const
nkGraphics::Shader * | getShader () const
EFFECT_TYPE | getType () const
void | setName (nkMemory::StringView value)

## Static Public Member Functions
static nkMemory::UniquePtr< FxaaEffect > | create (System *system=nullptr)

## Detailed Description

A Fast Approximate Anti-Aliasing effect.

This effect offers anti-aliasing capabilities using the fast approximate algorithm. It works on the final image to detect edges and smooth them up if they are too harsh. It is a good anti-aliasing solution in general cases thanks to its limited impact on performances. However, as it works on the final image rather than geometry information, it can also smooth up textures, sometimes making blurrier images or losing details. To search for a balance between quality and performances, some parameters are offered within the API.

## Constructor & Destructor Documentation

## ◆ FxaaEffect()

nkAstraeus::FxaaEffect::FxaaEffect | ( | System * | system | ) |
| noexcept

Default constructor. Alternatively, see FxaaEffect::create(), or EffectManager::createOrRetrieve().

Parameters

  system | The system the resource should live in.

## ◆ ~FxaaEffect()

virtual nkAstraeus::FxaaEffect::~FxaaEffect | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getSourceTexture()

nkGraphics::Texture* nkAstraeus::FxaaEffect::getSourceTexture | ( |  | ) | const

Returns
  The currently set source texture.

## ◆ getMinContrast()

float nkAstraeus::FxaaEffect::getMinContrast | ( |  | ) | const

Returns
  The currently set minimum contrast.

## ◆ getMinLuminance()

float nkAstraeus::FxaaEffect::getMinLuminance | ( |  | ) | const

Returns
  The currently set minimum luminance.

## ◆ getSmoothingStrength()

float nkAstraeus::FxaaEffect::getSmoothingStrength | ( |  | ) | const

Returns
  The currently set smoothing strength.

## ◆ getPreset()

FXAA_PRESET nkAstraeus::FxaaEffect::getPreset | ( |  | ) | const

Returns
  The currently set preset.

## ◆ getLuminanceAsGreenChannelOnly()

bool nkAstraeus::FxaaEffect::getLuminanceAsGreenChannelOnly | ( |  | ) | const

Returns
  Whether, currently, the luminance is derived only from the green channel (true) or not (false).

## ◆ setSourceTexture()

void nkAstraeus::FxaaEffect::setSourceTexture | ( | nkGraphics::Texture * | value | ) |

Sets the texture to use as an input of the effect. For best results, this texture needs to be in non-linear space, meaning that it should be either gamma corrected (see nkGraphics::Texture::setGammaCorrected()) or already corrected upfront. FXAA supposed to work on the final image, it can also be best to apply all tone mapping or post processing operations before applying this effect, depending on the result wanted.

Parameters

  value | The texture to filter.

Remarks
  This parameter can be altered even after the effect has been loaded and the new value will be taken instantly.

## ◆ setMinContrast()

void nkAstraeus::FxaaEffect::setMinContrast | ( | float | value | ) |

Sets the minimal contrast required to trigger the filter on a pixel. Contrast corresponds to the difference in intensity of a pixel with its surrounding. Having a higher value for this parameter means that the algorithm will filter less pixels, requiring a bigger local difference before triggering the filtering operation. However, lower values mean the filter will be triggered for less pixels, improving performances. Defaults to 0.57.

Parameters

  value | The wanted value, between [0.f, 1.f].

Remarks
  This parameter can be altered even after the effect has been loaded and the new value will be taken instantly.

## ◆ setMinLuminance()

void nkAstraeus::FxaaEffect::setMinLuminance | ( | float | value | ) |

Sets the minimal luminance (how light a pixel is) required before the filter being applied. Typically, darker environments' aliasing is less noticeable. Higher values mean the filter will trigger less often, requiring a lighter environment before triggering. Lower values will make the algorithm trigger more often, as even darker environment will get processed. This parameter can be used to control the impact on performances (lower = more quality, higher = quicker). Defaults to 0.54.

Parameters

  value | The wanted value, between [0.f, 1.f].

Remarks
  This parameter can be altered even after the effect has been loaded and the new value will be taken instantly.

## ◆ setSmoothingStrength()

void nkAstraeus::FxaaEffect::setSmoothingStrength | ( | float | value | ) |

Sets the strength of the smoothing operation. For lower values, the algorithm will output harsher edges. Higher values mean that the algorithm will try to better smooth the end result. Defaults to 0.75.

Parameters

  value | The wanted value, between [0.f, 1.f].

Remarks
  This parameter can be altered even after the effect has been loaded and the new value will be taken instantly.

## ◆ setPreset()

void nkAstraeus::FxaaEffect::setPreset | ( | FXAA_PRESET | value | ) |

Sets the preset to use as a basis of the algorithm. Defaults to FXAA_PRESET::DITHER_MEDIUM_RADIUS_5 as a general good compromise between quality and performances.

Parameters

  value | The preset wanted.

Remarks
  This parameter needs a reload of the effect if it needs to be altered on a loaded effect.

## ◆ setLuminanceAsGreenChannelOnly()

void nkAstraeus::FxaaEffect::setLuminanceAsGreenChannelOnly | ( | bool | value | ) |

Sets whether the luminance computing should only consider the green channel of a color, or not. Enabling it means that computing the luminance required for the algorithm is as simple as returning the green channel. With it off, all three channels of a color will participate in the luminance computing, using a dot product. By default, this parameter is off (use 3 channels).

Parameters

  value | Whether only the green channel (true) or all rgb channels (false) should be used when computing the luminance values.

## ◆ load()

virtual bool nkAstraeus::FxaaEffect::load | ( |  | ) |
| override virtual

Loads the effect and make it ready for rendering.

Returns
  Whether the loading went well (true) or not (false).

Implements nkAstraeus::Effect.

## ◆ unload()

virtual void nkAstraeus::FxaaEffect::unload | ( |  | ) |
| override virtual

Unloads the effect and its internal memory. After that, the effect is unusable for rendering.

Implements nkAstraeus::Effect.

## ◆ create()

static nkMemory::UniquePtr<FxaaEffect> nkAstraeus::FxaaEffect::create | ( | System * | system = `nullptr` | ) |
| static

Creates an instance of the class, and returns ownership over it.

Parameters

  system | The system the resource should live in. If left to nullptr, will seek the singleton instance of the system.

Returns
  Ownership over the created instance of the class.

Remarks
  The instance is not part of any manager if instantiated this way. If the resource's lifetime should be managed within the manager, then calling ComplexEffectManager::createOrRetrieve() might be a better option. Alternatively, registering it afterwards through ComplexEffectManager::record() is another option.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsAstraeus/Graphics/Effects/Fxaa/FxaaEffect.h